home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / CursorDevices.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  7KB  |  214 lines

  1. /*
  2.      File:        CursorDevices.h
  3.  
  4.      Contains:    Cursor Devices (mouse/trackball/etc) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __CURSORDEVICES__
  19. #define __CURSORDEVICES__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. #if PRAGMA_IMPORT_SUPPORTED
  33. #pragma import on
  34. #endif
  35.  
  36. #if PRAGMA_ALIGN_SUPPORTED
  37. #pragma options align=mac68k
  38. #endif
  39.  
  40. /*
  41.                        * * *  W A R N I N G  * * * 
  42.  
  43.     On currently shipping PowerMacs, the CursorDevices manager is implemented
  44.     in 68K code and emulated.  Unfortunately, the MixedMode glue in InterfaceLib
  45.     is incorrect.  It and the 1.0 version of this file had incorrect parameter
  46.     lists for most functions.
  47.     
  48.     As a first step to avoid runtime errors, the functions in this file were 
  49.     renamed (e.g. from"CrsrDevButtons" to "CursorDeviceButtons").  This will result
  50.     in a link time error if a PowerPC application tries to call the functions.
  51.     When InterfaceLib is fixed, the new names will be exported and PowerPC
  52.     code will then be able to call them.
  53.     
  54. */
  55. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  56. typedef short ButtonOpcode;
  57. /* ButtonOpcodes */
  58.  
  59. enum {
  60.     kButtonNoOp                    = 0,                            /* No action for this button */
  61.     kButtonSingleClick            = 1,                            /* Normal mouse button */
  62.     kButtonDoubleClick            = 2,                            /* Click-release-click when pressed */
  63.     kButtonClickLock            = 3                                /* Click on press, release on next press */
  64. };
  65.  
  66.  
  67. enum {
  68.     kButtonCustom                = 6                                /* Custom behavior, data = CursorDeviceCustomButtonUPP */
  69. };
  70.  
  71. /* Device Classes */
  72.  
  73. enum {
  74.     kDeviceClassAbsolute        = 0,                            /* a flat-response device */
  75.     kDeviceClassMouse            = 1,                            /* mechanical or optical mouse */
  76.     kDeviceClassTrackball        = 2                                /* trackball */
  77. };
  78.  
  79.  
  80. enum {
  81.     kDeviceClass3D                = 6                                /* a 3D pointing device */
  82. };
  83.  
  84. /* Structures used in Cursor Device Manager calls */
  85. struct CursorData {
  86.     struct CursorData *                nextCursorData;                /* next in global list */
  87.     Ptr                             displayInfo;                /* unused (reserved for future) */
  88.     Fixed                             whereX;                        /* horizontal position */
  89.     Fixed                             whereY;                        /* vertical position */
  90.     Point                             where;                        /* the pixel position */
  91.     Boolean                         isAbs;                        /* has been stuffed with absolute coords */
  92.     UInt8                             buttonCount;                /* number of buttons currently pressed */
  93.     long                             screenRes;                    /* pixels per inch on the current display */
  94.     short                             privateFields[22];            /* fields use internally by CDM */
  95. };
  96. typedef struct CursorData CursorData;
  97.  
  98. typedef CursorData *CursorDataPtr;
  99. struct CursorDevice {
  100.     struct CursorDevice *            nextCursorDevice;            /* pointer to next record in linked list */
  101.     CursorData *                    whichCursor;                /* pointer to data for target cursor */
  102.     long                             refCon;                        /* application-defined */
  103.     long                             unused;                        /* reserved for future */
  104.     OSType                             devID;                        /* device identifier (from ADB reg 1) */
  105.     Fixed                             resolution;                    /* units/inch (orig. from ADB reg 1) */
  106.     UInt8                             devClass;                    /* device class (from ADB reg 1) */
  107.     UInt8                             cntButtons;                    /* number of buttons (from ADB reg 1) */
  108.     UInt8                             filler1;                    /* reserved for future */
  109.     UInt8                             buttons;                    /* state of all buttons */
  110.     UInt8                             buttonOp[8];                /* action performed per button */
  111.     unsigned long                     buttonTicks[8];                /* ticks when button last went up (for debounce) */
  112.     long                             buttonData[8];                /* data for the button operation */
  113.     unsigned long                     doubleClickTime;            /* device-specific double click speed */
  114.     Fixed                             acceleration;                /* current acceleration */
  115.     short                             privateFields[15];            /* fields used internally to CDM */
  116. };
  117. typedef struct CursorDevice CursorDevice;
  118.  
  119. typedef CursorDevice *CursorDevicePtr;
  120. /* for use with CursorDeviceButtonOp when opcode = kButtonCustom */
  121. /*
  122.         This ProcPtr uses register based parameters on the 68k and cannot
  123.         be written in or called from a high-level language without the help of
  124.         mixed mode or assembly glue.
  125.  
  126.             typedef pascal void (*CursorDeviceCustomButtonProcPtr)(CursorDevicePtr ourDevice, short button);
  127.  
  128. */
  129.  
  130. #if GENERATINGCFM
  131. typedef UniversalProcPtr CursorDeviceCustomButtonUPP;
  132. #else
  133. typedef Register68kProcPtr CursorDeviceCustomButtonUPP;
  134. #endif
  135.  
  136. enum {
  137.     uppCursorDeviceCustomButtonProcInfo = kRegisterBased
  138.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA2, SIZE_CODE(sizeof(CursorDevicePtr)))
  139.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterD3, SIZE_CODE(sizeof(short)))
  140. };
  141.  
  142. #if GENERATINGCFM
  143. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  144.         (CursorDeviceCustomButtonUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, GetCurrentArchitecture())
  145. #else
  146. #define NewCursorDeviceCustomButtonProc(userRoutine)        \
  147.         ((CursorDeviceCustomButtonUPP) (userRoutine))
  148. #endif
  149.  
  150. #if GENERATINGCFM
  151. #define CallCursorDeviceCustomButtonProc(userRoutine, ourDevice, button)        \
  152.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppCursorDeviceCustomButtonProcInfo, (ourDevice), (button))
  153. #else
  154. /* (*CursorDeviceCustomButtonUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  155. #endif
  156. extern pascal OSErr CursorDeviceMove(CursorDevicePtr ourDevice, long deltaX, long deltaY)
  157.  TWOWORDINLINE(0x7000, 0xAADB);
  158.  
  159. extern pascal OSErr CursorDeviceMoveTo(CursorDevicePtr ourDevice, long absX, long absY)
  160.  TWOWORDINLINE(0x7001, 0xAADB);
  161.  
  162. extern pascal OSErr CursorDeviceFlush(CursorDevicePtr ourDevice)
  163.  TWOWORDINLINE(0x7002, 0xAADB);
  164.  
  165. extern pascal OSErr CursorDeviceButtons(CursorDevicePtr ourDevice, short buttons)
  166.  TWOWORDINLINE(0x7003, 0xAADB);
  167.  
  168. extern pascal OSErr CursorDeviceButtonDown(CursorDevicePtr ourDevice)
  169.  TWOWORDINLINE(0x7004, 0xAADB);
  170.  
  171. extern pascal OSErr CursorDeviceButtonUp(CursorDevicePtr ourDevice)
  172.  TWOWORDINLINE(0x7005, 0xAADB);
  173.  
  174. extern pascal OSErr CursorDeviceButtonOp(CursorDevicePtr ourDevice, short buttonNumber, ButtonOpcode opcode, long data)
  175.  TWOWORDINLINE(0x7006, 0xAADB);
  176.  
  177. extern pascal OSErr CursorDeviceSetButtons(CursorDevicePtr ourDevice, short numberOfButtons)
  178.  TWOWORDINLINE(0x7007, 0xAADB);
  179.  
  180. extern pascal OSErr CursorDeviceSetAcceleration(CursorDevicePtr ourDevice, Fixed acceleration)
  181.  TWOWORDINLINE(0x7008, 0xAADB);
  182.  
  183. extern pascal OSErr CursorDeviceDoubleTime(CursorDevicePtr ourDevice, long durationTicks)
  184.  TWOWORDINLINE(0x7009, 0xAADB);
  185.  
  186. extern pascal OSErr CursorDeviceUnitsPerInch(CursorDevicePtr ourDevice, Fixed resolution)
  187.  TWOWORDINLINE(0x700A, 0xAADB);
  188.  
  189. extern pascal OSErr CursorDeviceNextDevice(CursorDevicePtr *ourDevice)
  190.  TWOWORDINLINE(0x700B, 0xAADB);
  191.  
  192. extern pascal OSErr CursorDeviceNewDevice(CursorDevicePtr *ourDevice)
  193.  TWOWORDINLINE(0x700C, 0xAADB);
  194.  
  195. extern pascal OSErr CursorDeviceDisposeDevice(CursorDevicePtr ourDevice)
  196.  TWOWORDINLINE(0x700D, 0xAADB);
  197.  
  198. #endif
  199.  
  200. #if PRAGMA_ALIGN_SUPPORTED
  201. #pragma options align=reset
  202. #endif
  203.  
  204. #if PRAGMA_IMPORT_SUPPORTED
  205. #pragma import off
  206. #endif
  207.  
  208. #ifdef __cplusplus
  209. }
  210. #endif
  211.  
  212. #endif /* __CURSORDEVICES__ */
  213.  
  214.